//
//  PersonalHeaderVIew.m
//  WuShiCity
//
//  Created by chengjie on 16/7/5.
//  Copyright © 2016年 chengjie. All rights reserved.
//

#import "PersonalHeaderVIew.h"
#import "PersonalMessageViewController.h"

@interface PersonalHeaderVIew ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@end


@implementation PersonalHeaderVIew


- (void)awakeFromNib {
    
    self.personalPhoto.userInteractionEnabled = YES;
    self.personalPhoto.layer.cornerRadius = 30;
    self.personalPhoto.layer.masksToBounds = YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (IBAction)tapPersonalMessage:(id)sender {
    
//    PersonalMessageViewController *personalMessageVC = [[PersonalMessageViewController alloc] init];
//    [self.naVC pushViewController:personalMessageVC animated:NO];
    UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
    [pickerController setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
    pickerController.allowsEditing = YES;
    pickerController.delegate = self;
    [self.naVC presentViewController:pickerController animated:YES completion:^{
        nil;
    }];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
    
    UIImage *resultImage = [info objectForKey:UIImagePickerControllerEditedImage];
    self.personalPhoto.image = resultImage;
    [picker dismissViewControllerAnimated:YES completion:^{
        nil;
    }];
    
}
@end
